<%@ page language="java" pageEncoding="utf-8"%>
<%@page import="com.farm.web.constant.FarmConstant"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib uri="/view/conf/farmtag.tld" prefix="PF"%>
<style>
.configer_model_fieldComplete h4 {
	color: #ca5863;
	font-weight: 700;
}
</style>
<div class="configer_model_fieldComplete"
	id="callout-tables-responsive-overflow">
	<h4>${config.tables.table.name}</h4>
	<p>
		sql类型
		<code>${config.tables.type}</code>
	</p>
</div>
<div class="bs-example" data-example-id="striped-table">
	<table class="table table-striped">
		<thead>
			<tr>
				<th>#</th>
				<th>代码</th>
				<th>名称title</th>
				<th>类型</th>
				<th>长度</th>
				<th>表单</th>
				<th>主键</th>
				<th>必填</th>
				<th>查询</th>
			</tr>
		</thead>
		<tbody>
			<!--  {
                title=ID,
                code=ID,
                type=varchar,
                len=32,
                formType=text,
                primary=true,
                required=true,
                queryType=like
            }
		 -->
			<c:forEach items="${config.tables.table.fields }" var="node"
				varStatus="flag">
				<tr>
					<th scope="row">${flag.index+1 }<input type="hidden"
						class="form-control  input-sm" id="${node.code}_no2no_id"
						name="${node.code}_#_no2no" value="${flag.index+1 }"></th>
					<td>${node.code}<input type="hidden"
						class="form-control  input-sm" id="${node.code}_code_id"
						name="${node.code}_#_code" value="${node.code}"></td>
					<td><input type="text" class="form-control  input-sm"
						id="${node.code}_title_id" name="${node.code}_#_title"
						value="${empty attrs.list[flag.index].title?node.title: attrs.list[flag.index].title}"></td>
					<td>${node.type}<input type="hidden"
						class="form-control  input-sm" id="${node.code}_type_id"
						name="${node.code}_#_type" value="${node.type}"></td>
					<td><input type="text" class="form-control  input-sm"
						style="width: 50px;" id="${node.code}_len_id"
						name="${node.code}_#_len"
						value="${empty attrs.list[flag.index].len?node.len: attrs.list[flag.index].len}"></td>
					<td><select class="form-control input-sm  form-select-init"
						id="${node.code}_formType_id" name="${node.code}_#_formType"
						val="${empty attrs.list[flag.index].formType?node.formType: attrs.list[flag.index].formType}">
							<option value="text" ${node.formType=='text'? "selected":""}>text</option>
							<option value="textarea"
								${node.formType=='textarea'? "selected":""}>textarea</option>
							<option value="select" ${node.formType=='select'? "selected":""}>select</option>
					</select></td>

					<td><input type="checkbox" class="form-control input-sm"
						id="${node.code}_primary_id" name="${node.code}_#_primary"
						${node.primary?"checked":""}></td>

					<td><input type="checkbox" class="form-control input-sm"
						id="${node.code}_required_id" name="${node.code}_#_required"
						${node.required?"checked":""}></td>

					<td><select class="form-control input-sm  form-select-init"
						id="${node.code}_queryType_id" name="${node.code}_#_queryType" val="${empty attrs.list[flag.index].queryType?node.queryType: attrs.list[flag.index].queryType}">
							<option value="NONE"></option>
							<option value="like" ${node.queryType=='like'? "selected":""}>like</option>
							<option value="=" ${node.queryType=='='? "selected":""}>=</option>
					</select></td>
				</tr>
			</c:forEach>
		</tbody>
	</table>
</div>
<button onclick="submitParas()" class="btn btn-success btn-lg">提交</button>
<script type="text/javascript">
	$(function() {
		$('.form-select-init').each(function(i, obj) {
			$('option', obj).each(function(index, val) {
				if ($(val).attr('value') == $(obj).attr("val")) {
					$(val).attr('selected', true);
				}
			});
		});
	});
</script>

